package org.xwb.springcloud.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.xwb.springcloud.constant.MqConstant;

/**
 * 创建RabbitMQ的配置类
 *
 * @author 10564
 */
@Configuration
public class RabbitmqTopicConfig {
    @Bean
    public Queue topicQueueOne() {
        return new Queue(MqConstant.TOPIC_QUEUE_ONE);
    }

    @Bean
    public Queue topicQueueTwo() {
        return new Queue(MqConstant.TOPIC_QUEUE_TWO);
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(MqConstant.TOPIC_EXCHANGE_NAME);
    }

    @Bean
    public Binding topicBindingMatchingOneOrMore() {
        return BindingBuilder.bind(topicQueueOne()).to(topicExchange()).with(MqConstant.TOPIC_ROUTING_KEY_MATCHING_ONE_OR_MORE);
    }

    @Bean
    public Binding topicBindingMatchingOne() {
        return BindingBuilder.bind(topicQueueTwo()).to(topicExchange()).with(MqConstant.TOPIC_ROUTING_KEY_MATCHING_ONE);
    }
}